home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 60.zip / BS1 part 60 / Imagemaster d5.adf / piarc.lzh.parta / animrd.rexx < prev    next >
OS/2 REXX Batch file  |  1993-03-22  |  4KB  |  130 lines

  1. /*
  2.  * animrd.rexx
  3.  *
  4.  *  Written by: Pete Patterson & Ben Williams
  5.  * Last Update: February 27th, 1993
  6.  *         For: Black Belt Systems Amiga image processing software "IM"
  7.  * --------------------------------------------------------------------
  8.  *    Revision: 2.00
  9.  */
  10.  
  11. parse arg fullname aframe
  12. call pragma('stack',20000);
  13.  
  14. if ~show('L',"rexxsupport.library") then do
  15.   if ~addlib('rexxsupport.library',0,-30,0) then do
  16.     say 'We Have A Library Problem, Unable To Load "rexxsupport.library"';
  17.     say 'Cannot operate PI Modules without this library - sorry!';
  18.     'finish';
  19.     exit 10;
  20.     end;
  21.   end;
  22.  
  23. prtnme = 'IP_Port'; /* assume Image Professional */
  24. if show('P','IP_Port') = 0 then do
  25.   if show('P','IM_Port') = 0 then do
  26.     say "Can't find image processor's ARexx port!!!"; /* not running? */
  27.     say "This script requires IP, IM or IM F/c to run!";
  28.     exit(20);
  29.     end;
  30.   else do
  31.     prtnme = 'IM_Port';
  32.     end;
  33.   end;
  34.  
  35. cmdpath = 'c:';
  36. if open(fhandle,'rexx:picmdpath','read') then
  37.   do
  38.     cmdpath = readln(fhandle);
  39.     call close(fhandle);
  40.   end
  41.  
  42. if fullname = "" then
  43.   do
  44.     options results;
  45.     address command 'rx rxpi:GetFile.rexx';
  46.     if open(fhandle,'ram:IP_FNAME.tmp','read') then
  47.       do
  48.         fullname = readln(fhandle);
  49.         call close(fhandle);
  50.       end
  51.   end
  52.  
  53. thispath = gimmepath(fullname);
  54.  
  55.  
  56. /* --------------------------------------------------------------------- */
  57. /* ------------- BEGINNING of format-specific ARexx code --------------- */
  58. /* --------------------------------------------------------------------- */
  59.  
  60. address command cmdpath||'ANIMRD c "'||fullname||'"';
  61. if rc ~= 0 then do; address(prtnme); 'message "Cannot read '||fullname||' Error = '||rc||'"'; 'finish'; exit 0; end;
  62. call open(fhandle,'ram:IP_ANIMRD.tmp','read'); rstring = readln(fhandle); call close(fhandle);
  63. parse var rstring width '/' height '/' frames '/' type
  64. address command 'c:delete >nil: ram:IP_ANIMRD.tmp';
  65. if height < 0     then do; 'message "Bad Height:' height '"'; 'finish'; exit 0; end;
  66. if height > 32767 then do; 'message "Bad Height:' height '"'; 'finish'; exit 0; end;
  67. if width  < 0     then do; 'message "Bad Width:'  width  '"'; 'finish'; exit 0; end;
  68. if width  > 32767 then do; 'message "Bad Width:'  width  '"'; 'finish'; exit 0; end;
  69. if frames < 0     then do; 'message "# Frames is negative: '||width||'"'; 'finish'; exit 0; end;
  70. if frames > 32767 then do; 'message "Too many frames: '||width||'"'; 'finish'; exit 0; end;
  71.  
  72. address(prtnme);
  73. if aframe = "" then do; options results; 'askprop '||'"Load which frame?" 1 1 '||frames; frame = result; options; end;
  74. else do; frame = aframe; end;
  75.  
  76. 'imtofront';
  77. 'autoredraw 0';
  78. options results;
  79. 'newtargetted '||width||' '||height||' "'||gxname||'"'
  80. if rc ~= 0 then do; 'options'; "message Can't allocate buffer!"; 'autoredraw 1'; 'finish'; exit 0; end;
  81. bnum = result;
  82. 'backin '||bnum;
  83. plugadr = result;
  84. options;
  85. 'lockimage '||bnum;
  86. address command cmdpath||'ANIMRD d'||plugadr||' '||frame||' '||type||' "'||fullname||'"';
  87. 'unlockimage '||bnum;
  88. 'imtofront';
  89. 'autoredraw 1';
  90. 'finish';
  91. exit 0;
  92.  
  93. /* --------------------------------------------------------------------- */
  94. /* ---------------- END of format-specific ARexx code ------------------ */
  95. /* --------------------------------------------------------------------- */
  96.  
  97. gimmepath:
  98.   arg fullnamegx;
  99.     tempgx = reverse(fullnamegx);
  100.     lengx = length(fullnamegx);   /* get length of string */
  101.     slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
  102.     colondex = index(tempgx,':');  /* first occurance of ':' from right */
  103.     seploc = 0; /* assumes current dir, no path supplied */
  104.     if slashdex ~= 0 then do /* we assume we are in a DIR */
  105.       seploc = (lengx - slashdex)+1;
  106.       end;
  107.     else do
  108.       if colondex ~= 0 then do /* we assume we are on a device */
  109.         seploc = (lengx - colondex)+1;
  110.         end;
  111.       end;
  112.   gxname = substr(fullnamegx,seploc+1); /* if you ever need it */
  113.   gxpath = left(fullnamegx,seploc);
  114.   return(gxpath);
  115.  
  116. expandfilename:
  117.   parse arg jfile;
  118.   if index(jfile,':') = 0 then do
  119.     curdir = pragma(D);
  120.     if right(curdir,1) ~= ':' then do
  121.       if right(curdir,1) ~= '/' then do
  122.         if curdir ~= '' then do
  123.           curdir = curdir || '/';
  124.           end;
  125.         end;
  126.       end;
  127.     jfile = curdir||jfile;
  128.     end;
  129.   return(jfile);
  130.